﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ESN.Helpers
{
    public class CookiesHelper
    {
        public static void UpdateSubkey(string name, string subkey, string subvalue)
        {
            HttpCookie cookie;
            HttpRequest Request = HttpContext.Current.Request;
            HttpResponse Response = HttpContext.Current.Response;
            if (Request.Cookies[name] == null)
            {
                cookie = new HttpCookie(name);
                cookie[subkey] = subvalue;
            }
            else
            {
                cookie = Request.Cookies[name];
                cookie[subkey] = subvalue;
            }
            cookie.Expires = DateTime.Now.AddDays(30);
            Response.Cookies.Add(cookie);
        }
    }
}